package com.neu.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.neu.domain.ShoppingRegion;

import java.util.List;

/**
 * 
 **/
@Component
public class GetRegionService {

	@Autowired
	private ShoppingRegionService regionService;

	private static List<ShoppingRegion> ShoppingRegions;

	protected List<ShoppingRegion> getShoppingRegions() {
		if(ShoppingRegions==null){
			createRegion();
		}
		return ShoppingRegions;
	}

	private synchronized void createRegion(){
		if (ShoppingRegions == null) {
			ShoppingRegions = regionService.getAll();
		}
	}
}
